package com.example.demo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/calc")
public class CalcController {
    @RequestMapping("/sum")
    public String sum(Integer num1, Integer num2){
        // 1. 计算之前，先校验参数
        if(num1 == null || num2 == null){
            return "<h1>输入参数为空，请检查</h1>";
        }
        // 2. 计算并返回结果
        Integer sum = num1 + num2;
        return "<h1>计算机响应结果：" + sum + "</h1>";
    }
}
